if {![info exists perf_size] || $perf_size <= 0} {
  set perf_size 32
}
puts "NOTE: perf_size is ${perf_size}Byte"

set WaveID [wvGetCurrentWindow]
wvSetWindowTimeUnit -win $WaveID 1.000000 ns
wvSetSearchMode -win $WaveID -posedge

#"1 315000 x 1ns"
set cursor_result [wvGetCursor $WaveID -time]
set start_time [lindex $cursor_result 1]
#puts "start_time is ${start_time}ns"

set markers [wvGetMarker $WaveID]
set end_time [lindex $markers 1]
#puts "end_time is ${end_time} ns"

wvGetSelectedPureSignals -win $WaveID

set valid_signal [wvGetSelectedPureSignals -win $WaveID [wvSelectSignal -win $WaveID {( "G-perf" 2 )}]]
set ready_signal [wvGetSelectedPureSignals -win $WaveID [wvSelectSignal -win $WaveID {( "G-perf" 3 )}]]
#puts "$valid_signal, $ready_signal"
wvSelectSignal -win $WaveID {( "G-perf" 1 )}

set now_time $start_time
set sum_size 0
#puts "now_time is $now_time, end_time is $end_time"
while {$now_time <= $end_time} {
  set valid_value [wvGetSigValueByTime $valid_signal]
  set ready_value [wvGetSigValueByTime $ready_signal]
  #puts "valid_value is $valid_value"
  if {$valid_value == 1 && $ready_value == 1} {
    set sum_size [expr $sum_size + $perf_size]
    #puts "sum_size upto $sum_size"
  }
  wvSearchNext -win $WaveID
  set now_time [lindex [wvGetCursor $WaveID -time] 1]
  #puts "now_time is $now_time"
}


set proc_time [expr $end_time - $start_time]
set boundwidth [expr {double($sum_size)/double($proc_time)}]
puts "From ${start_time}ns to ${end_time}ns, Boundwidth is ${boundwidth}GBps"
